package com.aruba.filter;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.EmbossMaskFilter;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * EmbossMaskFilter 浮雕滤镜效果
 */
public class EmbossMaskFilterView extends View {
    public EmbossMaskFilterView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        setLayerType(LAYER_TYPE_SOFTWARE,null);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(Color.RED);


        Rect rectf = new Rect(10,10,300,300);
        canvas.drawRect(rectf,paint);

        canvas.translate(400,0);
        
        //第三个参数发现没什么用
        EmbossMaskFilter embossMaskFilter = new EmbossMaskFilter(new float[]{1,1,1},0.2f,1000,50);
        paint.setMaskFilter(embossMaskFilter);
        canvas.drawRect(rectf,paint);
    }
}
